﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	
  <head>
    <title>选择岗位和组织</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <%@include file="../include/include.jsp"%>
	<link rel="stylesheet" type="text/css" href="${webcontext}/css/public.css"/>
	<link rel="stylesheet" type="text/css" href="${webcontext}/css/datepicker.css"/>
	<link rel="stylesheet" type="text/css" href="${webcontext}/css/style_l.css"/>
	<link rel="stylesheet" type="text/css" href="${webcontext}/css/jquery.alerts.css" />
	<script type="text/javascript" src="${jspath}/jquery/jquery-1.4.4.js"></script>
	<script type="text/javascript" src="${jspath}/jquery/jquery.blockUI.js"></script>
    <script type="text/javascript" src="${jspath}/jquery/jquery.selectAll.js"></script>
    <script type="text/javascript" src="${jspath}/jquery/jquery.alerts.js"></script>
    <script type="text/javascript" src="${jspath}/load_layer.js"></script>
    <link rel="stylesheet" type="text/css" href="${webcontext}/css/validationEngine.jquery.css" />
    <script type="text/javascript" src="${jspath}/jquery/validate/jquery.validationEngine.js"></script>
    <script type="text/javascript" src="${jspath}/jquery/validate/jquery.validationEngine-zh.js"></script>
    <script type="text/javascript">
		$(function() {
						
			$("#save_add_zz").click(function() {
				
			    if($(":radio:checked").length == 0){
			    	jAlert("请选择组织！","提示信息");
			    	return;
			    }
				
			    var $tr = $(":radio:checked").parents("tr");
			    var $usrgrp = $("select option:selected");
			    var selectOrgCode = $(":radio:checked").val();
			    var defaultChecked = $("#defusrgrp").get(0).checked;
			    var checkval = 0;
			    var defaultusrgrp = "";
			    if(defaultChecked){
			    	checkval = 1;
			    	defaultusrgrp = $usrgrp.text();
			    	parent.$("#usrgrp_org_table tr td:nth-child(3)").find("div").html("");
				    parent.$("#usrgrp_org_table tr td:nth-child(3)").find(":hidden").val("0");
			    }
			    
			    var index = parent.$("#maxindex").val();
			    index = parseInt(index);
				parent.$("#usrgrp_org_table").append("<tr>"
				        +"<td class='align_m'><input type='radio' name='radioId' value='"+$("#userGroupId").val()+"'/></td>"
                        +"<td>"+$usrgrp.text()
                        +"<input type='hidden' id='userGroupOrgList["+index+"].userGroupCode'  name='userGroupOrgList["+index+"].userGroupCode' value='"+$usrgrp.val()+"'/>"
                        +"</td>"
                        +"<td><div>"+$usrgrp.text()
                        +"</div><input type='hidden' id='userGroupOrgList["+index+"].defaultUserGroup'  name='userGroupOrgList["+index+"].defaultUserGroup' value='"+checkval+"'/>"
                        +"</td>"
                        +"<td class='align_right'>"+$tr.find("td:eq(1)").text()
                        +"<input type='hidden' id='userGroupOrgList["+index+"].orgCode'  name='userGroupOrgList["+index+"].orgCode' value='"+selectOrgCode+"'/>"
                        +"</td>"
                        +"<td class='align_right'>"+$tr.find("td:eq(2)").text()+"</td>"
                        +"<td class='align_right'>"+$tr.find("td:eq(3)").text() +"</td>"
                        +"</tr>");
				index = parseInt(index) + 1;
			    parent.$("#maxindex").val(index);
			    
			    parent.$("#usrgrp_org_table tr:odd").attr("class", "odd");
			    parent.$("#usrgrp_org_table tr:even").attr("class", "even");
				removeLayer();
				
				
			});
			
			$("#cancel_add_zz").click(function() {
				removeLayer();
			});
			
			$("#userGroupId").change(function() {
				
				if($(this).val()!=""){
					$.get("${webcontext}/common/getOrgByUsrGrpCode?usrGrpCode="+$(this).val() + "&&ownerId=${ownerId}",{
					  },function(data, textStatus){
						  // alert(data);
						  $("#orgTable tr:gt(0)").empty();
						  
						  $(data).appendTo("#orgTable");
			
						  // 设置数据展示表格奇、偶行的背景色
						  $(".data_tab tr:odd").addClass("odd");
						  $(".data_tab tr:even").addClass("even");
						  // 设置鼠标滑过时数据展示表格行背景色的变化
						  $(".data_tab tr").mouseover(function() {
							  $(this).addClass("over");
						  }).mouseout(function() {
							  $(this).removeClass("over");
						  });
					});
				} else {
					$("#orgTable tr:gt(0)").empty();
			    }
				
			}).trigger("change");


		});
	</script>  
	<style>
			html, body {
				overflow-x:hidden;
				overflow-y:auto;
			}			
	</style>
  </head>

  <body>
	
	<!-- content -->
	<div id="content">
		<!-- wrap -->
		<form id="view_employee" action="${webcontext}/dm/sgm/maintain/createEmployee" method="post" >
		
		<div id="wrap">
		<!-- block_div : default-hidden -->
			<div class="block_div" style="display:block;" id="add_zz_block">
				<div class="title">
					<span>新增岗位与组织</span>
				</div>
				<div class="spliter h_5"></div>
				<table class="block_tab">
					<tr>
						<td class="label">岗位名称：</td>
						<td>
						
 						 <select id = "userGroupId"  class="sel"> 
						    <option value="">请选择</option>
					    	<core:forEach items="${userGroups}" var="userGroup"> 
								<option value="${userGroup.userGroupCode}">${userGroup.userGroupName}</option>
							</core:forEach> 
						</select> 	
						</td>  
						<td class="label">默认岗位</td>   
						<td><input id="defusrgrp" name = "defusrgrp" type="checkbox" value="1" disabled="disabled"/></td>              
					</tr>
				</table>
                 <div class="data_div">
                        <table id="orgTable" class="data_tab">
                            <tr>
                              <th class="w_5 center">选择</th>
                                <th class="">组织名称</th>
                                <th class="">组织主管</th>
                                <th class="">上级组织名称</th>
                            </tr>
                        </table>
                    </div>
                <div class="spliter h_5"></div>                
                <div class="btn_div">
                	<input type="button" class="btn" value="确定" id="save_add_zz"/>
                    <input type="button" class="btn" value="取消" id="cancel_add_zz"/>
                </div>
				
			</div>
			<!-- /block_div -->
		</div>
		</form>
		<!-- /wrap -->
	</div>
	<!-- /content -->

  </body>
</html>
